package com.example.demo.web.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * @author ayatsuji
 * @date 2022-03-06 10:53
 * @since
 */
public class RequestUtils {
    public static HttpServletRequest getCurrentRequest() {
        return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
    }

    public static String getRequestHeader(String headerKey) {
        return getCurrentRequest().getHeader(headerKey);
    }
}
